import static org.junit.Assert.*;

import java.util.LinkedList;
import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;


public class ValueTest {

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testGetValueHighestCard() {
		LinkedList<Card> cards = new LinkedList<Card>();
		cards.add(new Card(0, 0));
		cards.add(new Card(3, 6));
		cards.add(new Card(2, 10));
		cards.add(new Card(1, 5));
		cards.add(new Card(0, 9));
		
		Hand hand = new Hand();
		for(Card c: cards)
		{
			hand.giveCard(c);
		}
		
		List<Integer> list = new LinkedList<Integer>();
		list.add(0);
		list.add(10);
		list.add(9);
		list.add(6);
		list.add(5);
		list.add(0);
		
		List<Integer> list2 = hand.getValue();
		
		compareList(list, list2);
	}

	private void compareList(List<Integer> list, List<Integer> list2)
	{
		assertEquals(list.size(), list2.size());
		
		for(int i = 0; i < list.size(); i++)
		{
			assertEquals(list.get(i), list2.get(i));
		}
	}
	
	@Test
	public void testGetValuePair() {
		LinkedList<Card> cards = new LinkedList<Card>();
		cards.add(new Card(0, 0));
		cards.add(new Card(3, 6));
		cards.add(new Card(2, 10));
		cards.add(new Card(3, 0));
		cards.add(new Card(0, 9));
		
		Hand hand = new Hand();
		for(Card c: cards)
		{
			hand.giveCard(c);
		}
		
		List<Integer> list = new LinkedList<Integer>();
		list.add(1);
		list.add(0);
		
		List<Integer> list2 = hand.getValue();
		
		compareList(list, list2);
	}
	
	@Test
	public void testGetValueTwoPairs() {
		LinkedList<Card> cards = new LinkedList<Card>();
		cards.add(new Card(0, 0));
		cards.add(new Card(3, 6));
		cards.add(new Card(2, 10));
		cards.add(new Card(3, 0));
		cards.add(new Card(0, 6));
		
		Hand hand = new Hand();
		for(Card c: cards)
		{
			hand.giveCard(c);
		}
		
		List<Integer> list = new LinkedList<Integer>();
		list.add(2);
		list.add(6);
		list.add(0);
		
		List<Integer> list2 = hand.getValue();
		
		compareList(list, list2);
	}

	@Test
	public void testGetValueThree() {
		LinkedList<Card> cards = new LinkedList<Card>();
		cards.add(new Card(0, 0));
		cards.add(new Card(3, 6));
		cards.add(new Card(2, 10));
		cards.add(new Card(3, 0));
		cards.add(new Card(0, 0));
		
		Hand hand = new Hand();
		for(Card c: cards)
		{
			hand.giveCard(c);
		}
		
		List<Integer> list = new LinkedList<Integer>();
		list.add(3);
		list.add(0);
		
		List<Integer> list2 = hand.getValue();
		
		compareList(list, list2);
	}

	@Test
	public void testGetValueFlush() {
		LinkedList<Card> cards = new LinkedList<Card>();
		cards.add(new Card(0, 0));
		cards.add(new Card(3, 3));
		cards.add(new Card(2, 1));
		cards.add(new Card(3, 4));
		cards.add(new Card(0, 2));
		
		Hand hand = new Hand();
		for(Card c: cards)
		{
			hand.giveCard(c);
		}
		
		List<Integer> list = new LinkedList<Integer>();
		list.add(4);
		list.add(4);
		
		List<Integer> list2 = hand.getValue();
		
		compareList(list, list2);
	}

	@Test
	public void testGetValueColor() {
		LinkedList<Card> cards = new LinkedList<Card>();
		cards.add(new Card(0, 0));
		cards.add(new Card(0, 6));
		cards.add(new Card(0, 10));
		cards.add(new Card(0, 0));
		cards.add(new Card(0, 6));
		
		Hand hand = new Hand();
		for(Card c: cards)
		{
			hand.giveCard(c);
		}
		
		List<Integer> list = new LinkedList<Integer>();
		list.add(5);
		list.add(10);
		list.add(6);
		list.add(6);
		list.add(0);
		list.add(0);
		
		List<Integer> list2 = hand.getValue();
		
		compareList(list, list2);
	}

	@Test
	public void testGetValueFull() {
		LinkedList<Card> cards = new LinkedList<Card>();
		cards.add(new Card(0, 0));
		cards.add(new Card(3, 6));
		cards.add(new Card(2, 6));
		cards.add(new Card(3, 0));
		cards.add(new Card(0, 6));
		
		Hand hand = new Hand();
		for(Card c: cards)
		{
			hand.giveCard(c);
		}
		
		List<Integer> list = new LinkedList<Integer>();
		list.add(6);
		list.add(6);
		list.add(0);
		
		List<Integer> list2 = hand.getValue();
		
		compareList(list, list2);
	}

	@Test
	public void testGetValueFour() {
		LinkedList<Card> cards = new LinkedList<Card>();
		cards.add(new Card(0, 6));
		cards.add(new Card(3, 6));
		cards.add(new Card(2, 6));
		cards.add(new Card(3, 0));
		cards.add(new Card(1, 6));
		
		Hand hand = new Hand();
		for(Card c: cards)
		{
			hand.giveCard(c);
		}
		
		List<Integer> list = new LinkedList<Integer>();
		list.add(7);
		list.add(6);
		
		List<Integer> list2 = hand.getValue();
		
		compareList(list, list2);
	}

	@Test
	public void testGetValueStraightFlush() {
		LinkedList<Card> cards = new LinkedList<Card>();
		cards.add(new Card(0, 2));
		cards.add(new Card(0, 6));
		cards.add(new Card(0, 3));
		cards.add(new Card(0, 5));
		cards.add(new Card(0, 4));
		
		Hand hand = new Hand();
		for(Card c: cards)
		{
			hand.giveCard(c);
		}
		
		List<Integer> list = new LinkedList<Integer>();
		list.add(9);
		list.add(6);
		
		List<Integer> list2 = hand.getValue();
		
		compareList(list, list2);
	}
}
